﻿<CodeSnippets
    xmlns="http://schemas.microsoft.com/VisualStudio/2008/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>spchol307_ex2_webpart_createchildcontrols</Title>
      <Shortcut>spchol307_ex2_webpart_createchildcontrols</Shortcut>
      <Description>Code snippet for SPCHOL307 Ex2 CreateChildControls</Description>
      <Author>Microsoft Corporation</Author>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Code Language="csharp">
        <![CDATA[protected override void CreateChildControls()
{
    base.CreateChildControls();

    Label lbl = new Label();

    TextBox txt = new TextBox();
    Button btn = new Button();
    DateTime dt = DateTime.Now;
    btn.Text = "Show All Lists";
    btn.Click += delegate
    {
        do
        {
            SPWebCollection Webs;
            SPListCollection lists;
            Webs = SPContext.Current.Site.AllWebs;
            foreach (SPWeb web in Webs)
            {
                lists = web.Lists;
                foreach (SPList list in lists)
                    lbl.Text = lbl.Text + "<br>" + list.Title;
            }
        }
        while (dt.AddSeconds(int.Parse(txt.Text)).CompareTo(DateTime.Now) > 0);
    };
    Controls.Add(txt);
    Controls.Add(btn);

    Controls.Add(lbl);
}]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>
